package com.kuangstudy.io.demo;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Arrays;

/**
 * ClassName: Demo12
 * date: 2021/07/16 14:09:59
 *一次读取多个字节
 * @author zlk
 */
public class Demo12 {
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("e:\\2.txt");
        byte[] bytes = new byte[1024];//存储读取到的多个字节
        int i = 0;
        while ((i=fis.read(bytes))!=-1){
            System.out.println(new String(bytes,0,i));//i表示读取的字符长度
        }
        fis.close();
    }
}
